﻿@model LimestoneMVC.Models.EditPageModel
<link href="/Content/Limestone.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="/scripts/tiny_mce/tiny_mce.js"></script>
<script type="text/javascript" src="/Scripts/limestone.js"></script>
<script type="text/javascript">
    $(function () {
        //$("button, input:submit, .button").button();
        var parentPath = $('#Page_Path').val();
        parentPath = parentPath.substr(0, parentPath.lastIndexOf('/') + 1);

        $('#Page_Name').bind('keyup', function () {
            var el = $(this);
            $('#Page_Path').val(parentPath + el.val());
        });
    });

    tinyMCE.init({
        // General options
        mode: "textareas",
        theme: "advanced",
        plugins: "autolink,lists,spellchecker,pagebreak,style,layer,table,save,advhr,advimage,advlink,emotions,iespell,inlinepopups,insertdatetime,preview,media,searchreplace,print,contextmenu,paste,directionality,fullscreen,noneditable,visualchars,nonbreaking,xhtmlxtras,template",

        // Theme options
        theme_advanced_buttons1: "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect",
        theme_advanced_buttons2: "cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,forecolor,backcolor",
        theme_advanced_buttons3: "tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,iespell,media,advhr,|,print,|,fullscreen",
        theme_advanced_buttons4: "styleprops,spellchecker,|,cite,abbr,acronym,del,ins,attribs,|,visualchars,nonbreaking,blockquote,pagebreak,|,insertfile,insertimage",
        theme_advanced_toolbar_location: "top",
        theme_advanced_toolbar_align: "left",
        theme_advanced_statusbar_location: "bottom",
        theme_advanced_resizing: true,

        // Skin options
        skin: "o2k7",
        skin_variant: "silver",

        // Example content CSS (should be your site CSS)
        content_css: "/content/site.css",

        // Drop lists for link/image/media/template dialogs
        template_external_list_url: "js/template_list.js",
        external_link_list_url: "js/link_list.js",
        external_image_list_url: "js/image_list.js",
        media_external_list_url: "js/media_list.js"

    });
</script>
<div class="limestonePageEditor">
    <h2>
        Create/Edit page</h2>
    @using (Html.BeginForm("Save", "Editor"))
    {
        <h3>
            Page properties</h3>
        <div class="pageInfoContainer panel">
            @Html.LabelFor(f => f.Page.Title)
            @Html.EditorFor(f => f.Page.Title)
            <br />
            @Html.LabelFor(f => f.Page.Name)
            @Html.EditorFor(f => f.Page.Name)
            @Html.HiddenFor(f => f.Page.OriginalName)
            <div class="pageProperties">
                @Html.LabelFor(f => f.Page.Hidden)
                @Html.EditorFor(f => f.Page.Hidden)
                <br />
                @Html.LabelFor(f => f.Page.Path)
                @Html.EditorFor(f => f.Page.Path)
                <br />
                @Html.LabelFor(f => f.Page.TemplatePath)
                @Html.EditorFor(f => f.Page.TemplatePath)
                <br />
                @Html.HiddenFor(f => f.Page.SortChildPagesBy)
                @Html.HiddenFor(f => f.Page.SortValue)
            </div>
        </div>

        <h3>
            Fields</h3>
        <div class="panel fieldEditor">
            @foreach (var field in Model.Page.Fields)
            {
                <div class="field">
                    @Html.LabelFor(f => f.Page.Fields[field.Name], field.Settings.Title)
                    @Html.EditorFor(p => p.Page.Fields[field.Name])
                </div>
            }
        </div>
        <div class="buttonContainer">
            <input type="submit" value="Save" class="button" />
            <input type="button" value="Cancel" class="button" onclick="document.location='@Model.CancelUrl';"/>
        </div>
    }
</div>
